package com.egg.action.common;

import org.apache.log4j.Logger;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;

import com.opensymphony.xwork2.ActionSupport;

@ParentPackage("default")
@Namespace(value="/")
@Results( { @Result(location = "/common/500.jsp") })
public class CommonExceptionAction extends ActionSupport {

	private static final long serialVersionUID = -7805276499749777051L;

	Logger logger = Logger.getLogger(this.getClass());

	private Exception exception;

	public Exception getException() {
		return exception;
	}

	public void setException(Exception exception) {
		this.exception = exception;
	}

	@Action(value = "commonException")
	public String index() {

		if (this.exception != null) {
			logger.debug("------------ 记录下500 -----------");
			logger.debug(exception.getMessage());
			exception.printStackTrace();
		}

		return SUCCESS;
	}
}

